/*
    21. Write a program in C to convert a string to uppercase.

    Test Data :
    Input a string in lowercase : the quick brown fox jumps over the lazy dog

    Expected Output :

    Here is the above string in UPPERCASE :                                
    THE QUICK BROWN FOX JUMPS OVER THE LAZY DOG.
*/

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>

#define MAX_LEN 1024
#define MAX_STR 256

char* getstr(char *str)
{
    char ch;
    char *p = str;
    while((ch = getchar()) != '\n'){
        *p++ = ch;
    }
    *p = '\0';
    return str;
}

char* convertUpper(char *str)
{
    char *p = str;
    while(*p){
        if(islower(*p)){
            *p = *p - 32;
        }
        p++;
    }
    return str;
}

int main(void)
{
    char *str = malloc(MAX_LEN);
    printf("Input a string in lowercase : ");
    getstr(str);
    convertUpper(str);
    printf("Here is the above string in UPPERCASE : %s\n", str);

    return 0;
}